import { CommonResult } from "../types/global"
import { StatsItem, TaskItem } from "../types/task"
import { http } from "../utils/http"

export const listTaskAPI = () => {
	return http<TaskItem[]>({
		url: '/fanqie/tasks/listTask',
		method: 'GET',
	})
}

export const listHistoryTaskAPI = () => {
	return http<TaskItem[]>({
		url: '/fanqie/taskHistory/listHistoryTask',
		method: 'GET',
	})
}


export const deleteTaskAPI = (taskId : number) => {
	return http<TaskItem[]>({
		url: '/fanqie/taskHistory/deleteTask',
		method: 'DELETE',
		data: {
			id: taskId
		}
	})
}

export const completeTaskAPI = (taskId : number) => {
	return http<CommonResult>({
		url: '/fanqie/taskHistory/handleCompleteTask',
		method: 'POST',
		data: {
			id: taskId
		}
	})
}

export const addTaskAPI = (data : TaskItem) => {
	return http<TaskItem[]>({
		url: '/fanqie/tasks/addTask',
		method: 'POST',
		data
	})
}

export const listStatsAPI = () => {
	return http<StatsItem[]>({
		url: '/fanqie/taskStatistics/listStatistics',
		method: 'GET'
	})
}